package project16;

public class Test {
    public static void main(String[] args) {
     String[] std={"妈妈","爸爸","姐姐"};
     String name="李华";
     person master=new person(name,std);
     dog a=new dog(master,"小花");
     a.scream("李华");
     a.scream("爸爸");
     a.scream("陌生人");
    }
}
class dog
{
    private person master;
    private String name;

    public dog() {
    }

    public dog(person master, String name) {
        this.master = master;
        this.name = name;
    }

    public void scream(String a)
    {
        int flag=0;
        if(a.equals(master.getName()))
        {
            System.out.println("开心地跳");
            flag=1;
        }
        else{
        String[] std=master.getFamily();
        for (int i = 0; i <std.length; ++i) {
            if (a.equals(std[i])) {
                System.out.println("平常地吃东西");
                flag = 1;
                break;
            }
        }
    }
        if(flag==0)
        System.out.println("刺耳的尖叫");
    }
}
class person
{
    private String name;
    private String[] family;

    public person(String name, String[] family) {
        this.name = name;
        this.family = family;
    }

    public person() {
    }

    public String getName() {
        return name;
    }

    public String[] getFamily() {
        return family;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setFamily(String[] family) {
        this.family = family;
    }
}
